<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<style type="text/css">
.ui-layout-north {
	z-index: 20 !important;
	overflow: visible !important;;
}

.ui-layout-north .ui-layout-unit-content {
	overflow: visible !important;
}

.ui-widget {
	font-size: 9px !important;
}

.size {
	width: 750px;
	position: relative;
	left: 18%;
	top: 10%;
}

.centro {
	top: 50%
}

.tabela {
	width: 750px;
}
</style>

	<title>Relatório</title>
</h:head>

<h:body>
	<ui:decorate template="/templateBase.xhtml">
		<ui:define name="center">
			<p:growl life="3000" id="growl" />
			<h:form id="formRelatorio">
				<br />
				<br />
				<br />
				<p:panel header="Relatórios - Gestão de Eventos" styleClass="size"
					footer="Integração - Portal de Serviços e Comunicação">
					<br />
					<p:tabView>
						<br />
						<p:tab title="Emissão de Certificados - Por evento">
							<br />

							<h:outputText value="ID Evento: " />
							<h:panelGrid columns="4">
								<p:inputText size="8" value="#{eventoBacking.evSalvar.id}"
									readonly="true" />
								<p:inputText size="80" readonly="true"
									value="#{eventoBacking.evSalvar.nomeEvento}" />
								<p:commandButton icon="ui-icon-search"
									oncomplete="dlgPesquisa.show()"
									update=":formPesquisa:tblPesquisa" />

							</h:panelGrid>

							<h:panelGrid>
								<h:outputText value="Local" />
								<p:inputText size="65" readonly="true"
									value="#{eventoBacking.evSalvar.localEvento.descricao}" />
							</h:panelGrid>

							<h:panelGrid columns="3">

								<h:panelGrid>
									<h:outputText value="Data Início" />
									<p:inputText size="15" readonly="true"
										value="#{eventoBacking.evSalvar.dataInicial}">
										<f:convertDateTime pattern="dd/MM/yyyy" />
									</p:inputText>
								</h:panelGrid>

								<h:panelGrid>
									<h:outputText value="a" />
								</h:panelGrid>

								<h:panelGrid>
									<h:outputText value="Data Final" />
									<p:inputText size="15" readonly="true"
										value="#{eventoBacking.evSalvar.dataFinal}">
										<f:convertDateTime pattern="dd/MM/yyyy" />
									</p:inputText>
								</h:panelGrid>

							</h:panelGrid>
							<br />
							<p:separator />
							<br />
							<div align="center">
								<h:panelGrid columns="2">

									<p:commandButton value="Emitir relatório" ajax="false"
										actionListener="#{eventoBacking.geraRelatorioPorEvento}"
										onclick="this.form.target='_blank'" icon="ui-icon-print" />
									<p:commandButton value="Cancelar" icon="ui-icon-cancel" />

								</h:panelGrid>
							</div>
						</p:tab>

						<p:tab title="Envio de E-mail">
							<br />
							<h:panelGrid columns="4">

								<p:inputText size="8" value="#{eventoBacking.evSalvar.id}"
									readonly="true" />
								<p:inputText size="80" readonly="true"
									value="#{eventoBacking.evSalvar.nomeEvento}" />
								<p:commandButton icon="ui-icon-search"
									oncomplete="dlgPesquisa.show()"
									update=":formPesquisa:tblPesquisa" />
							</h:panelGrid>

							<h:panelGrid>
								<h:outputText value="Local" />
								<p:inputText size="65" readonly="true"
									value="#{eventoBacking.evSalvar.localEvento.descricao}" />
							</h:panelGrid>


							<br />
							<p:separator />
							<br />
							<p:dataTable paginator="true" rows="10" id="tblParticipantes"
								emptyMessage="Nenhum participante encontrado para o evento selecionado!"
								value="#{eventoBacking.listaParticipantes}" var="pe"
								rowKey="#{pe.id}"
								selection="#{eventoBacking.participantesSelecionados}">

								<p:column selectionMode="multiple">

								</p:column>

								<p:column headerText="Nome">
									<h:outputText value="#{pe.participante.nome}" />
								</p:column>
								<p:column headerText="E-mail">
									<div align="center">
										<h:outputText value="#{pe.participante.email}" />
									</div>
								</p:column>
								<p:column headerText="Tipo de Participação">
									<div align="center">
										<h:outputText value="#{pe.tipo.descricao}" />
									</div>
								</p:column>

							</p:dataTable>
							<br />
							<p:separator />
							<br />
							<div align="center">
								<h:panelGrid columns="2">
									<p:commandButton value="Enviar E-mail (s)"
										icon="ui-icon-mail-closed" oncomplete="dlgEnviaEmail.show()"
										action="#{eventoBacking.contaPartSelecionadoEmail}"
										update=":formEnviaEmail" />
									<p:commandButton value="Limpar seleção" icon="ui-icon-cancel" />
								</h:panelGrid>
							</div>
						</p:tab>
					</p:tabView>
				</p:panel>
			</h:form>

			<p:dialog header="Pesquisa Eventos" widgetVar="dlgPesquisa"
				showEffect="clip" hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="600"
				height="300">

				<h:form id="formPesquisa" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">

					<p:dataTable value="#{eventoBacking.listaEventos}" var="e"
						id="tblPesquisa" rows="10">

						<p:column headerText="ID">
							<h:outputText value="#{e.id}" />
						</p:column>

						<p:column headerText="Nome do Evento">
							<h:outputText value="#{e.nomeEvento}" />
						</p:column>

						<p:column headerText="Curso">
							<h:outputText value="#{e.curso.nome}" />
						</p:column>

						<p:column headerText="Local">
							<h:outputText value="#{e.localEvento.descricao}" />
						</p:column>

						<p:column>
							<p:commandButton icon="ui-icon-check"
								actionListener="#{eventoBacking.selecionaEvento(e)}"
								oncomplete="dlgPesquisa.hide()" update=":formRelatorio" />
						</p:column>

					</p:dataTable>
				</h:form>
			</p:dialog>

			<p:dialog header="Enviar E-mail" widgetVar="dlgEnviaEmail"
				showEffect="clip" hideEffect="clip" closable="true"
				footer="Integração - Portal de Serviços e Comunicação" width="300"
				height="140">

				<h:form id="formEnviaEmail" prependId="false"
					acceptcharset="ISO-8859-1" lang="pt">
					<br />
					<h4>Deseja enviar e-mail aos
						#{eventoBacking.totalPartSelecionado} participantes selecionados?</h4>
					<br />
					<br />
					<div align="center">
						<h:panelGrid columns="2">
							<p:commandButton value="Enviar" icon="ui-icon-check" ajax="false"
								actionListener="#{eventoBacking.enviaCertificado}"
								update=":growl" />
							<p:commandButton value="Limpar " icon="ui-icon-cancel" />
						</h:panelGrid>
					</div>

				</h:form>
			</p:dialog>

		</ui:define>
	</ui:decorate>
</h:body>
</html>